package com.sskj.gcc.presenter;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.gcc.bean.GuideListBean;
import com.sskj.gcc.bean.ZixunListBean;
import com.sskj.gcc.http.HttpConfig;
import com.sskj.gcc.ui.fragment.DiscoveryFragment;
import com.sskj.gocoin.MyAppLication;
import com.sskj.gocoin.m.bean.AgentNumBean;
import com.sskj.gocoin.p.base.BasePresenter;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;

import java.util.List;

import io.reactivex.Flowable;

public class DiscoveryFragmentPresenter extends BasePresenter<DiscoveryFragment> {
    public void getData(String page) {
        OkGo.<HttpData<PageBean<ZixunListBean>>>post(HttpConfig.BASE_URL + HttpConfig.GET_ZIXUN_LIST)
                .params("p", page)
                .params("s", 3)
                .execute(new JsonCallBack<HttpData<PageBean<ZixunListBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<PageBean<ZixunListBean>>> response) {
                        mView.updateUI(response.body().getData().getList());
                    }
                });

    }

    public void requestRelieveBusiness() {
        OkGo.<HttpData<Object>>post(HttpConfig.BASE_URL + HttpConfig.RELIEVE_BUSINESS)
                .execute(new JsonCallBack<HttpData<Object>>() {
                    @Override
                    public void onSuccess(Response<HttpData<Object>> response) {
//                        alertDialog.dismiss();
                        if (response.body().getCode() == 200) {
                            mView.onRelieveBusinessSuccess();
                            ToastUtil.showShort(response.message());
                        }
                    }

                    @Override
                    public void onError(Response<HttpData<Object>> response) {
                        super.onError(response);
//                        alertDialog.dismiss();
                    }
                });
    }

}
